package com.cct.digitalarchapi.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cct.digitalarchapi.pojo.DigitalArchMain;
import com.cct.digitalarchapi.pojo.dto.ArchMainDto;
import com.cct.digitalarchapi.pojo.dto.ArchTypeAndNumDto;
import com.cct.digitalarchapi.pojo.dto.CateAndYearDto;
import com.cct.digitalarchapi.pojo.vo.ArchMainCountVo;
import com.cct.digitalarchapi.pojo.vo.ArchMainMonthVo;
import com.cct.digitalarchapi.pojo.vo.ArchMainTypeVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface DigitalArchMainMapper extends BaseMapper<DigitalArchMain> {

    void addArchMain(DigitalArchMain digitalArchMain);

    void  updateVisitCount(@Param("archMainId") int archMainId);

    void updateDownCount(@Param("archMainId") int archMainId);

    IPage<DigitalArchMain> qryAllArchMain(IPage<DigitalArchMain> page);

    DigitalArchMain queryHaveRec(@Param("archMainCode") String archMainCode);

    DigitalArchMain qryArchMainById(@Param("archMainId") int archMainId);

    IPage<DigitalArchMain> qryAllArchMainByType(IPage<DigitalArchMain> page,@Param("accessState") int accessState,@Param("archState") int archState,
                                                @Param("archCateCode") String archCateCode,@Param("archDeptCode") String archDeptCode,
                                                @Param("username") String username,@Param("staffCode") String staffCode,
                                                @Param("archTitle") String archTitle,@Param("archPeriod") int archPeriod,@Param("visitCount") int visitCount,
                                                @Param("borrowCount") int borrowCount,@Param("submitYear") String submitYear,@Param("archDeptHotName") String archDeptHotName);
    List<DigitalArchMain> qryMainCode(@Param("archMainCode") String archMainCode);

    void updateArchMainState(@Param("archMainId") int archMainId,@Param("archState") int archState,@Param("auditUser") String auditUser);

    IPage<DigitalArchMain> qryAllArchMainWithList(IPage<DigitalArchMain> page,@Param("accessState") int accessState,@Param("archState") String archState,
                                                @Param("archCateCode") String archCateCode,@Param("archDeptCode") String archDeptCode,
                                                @Param("username") String username,@Param("staffCode") String staffCode,
                                                @Param("archTitle") String archTitle,@Param("archPeriod") int archPeriod,@Param("visitCount") int visitCount,
                                                  @Param("borrowCount") int borrowCount,@Param("submitYear") String submitYear,@Param("archDeptHotName") String archDeptHotName);

    List<ArchMainCountVo> getCateCount();

    List<ArchMainMonthVo> getCountByMonth(@Param("archCateCode") String archCateCode,@Param("startDate") String startDate,@Param("endDate") String endDate);


    List<ArchMainMonthVo> getCountYearByMonth(@Param("archCateCode") String archCateCode,@Param("year") String year);

    List<ArchMainCountVo> getCateCountToday(@Param("auditTime") String auditTime);

    int getSubmitCountToday(@Param("time") String time);

    int getAllCountByState(@Param("archState") int archState);

    int getPassCountToday(@Param("auditTime") String auditTime,@Param("archState") int archState);

    int getAllPassCountYear(@Param("year") String year);

    int getAllSubmitCountYear(@Param("year") String year);

    int getSubmitCountMonth(@Param("param") String param);

    int getAuditCountMonth(@Param("param") String param);

    int getNoPassCountMonth(@Param("param") String param);

    void updateArchMainInfo(@Param("archMainId") int archMainId, @Param("archMainTitle") String archMainTitle, @Param("archPeriod") int archPeriod,
                            @Param("notes") String notes);

    int getStateByMainCode(@Param("archMainCode") String archMainCode);


    void addImportArchMain(DigitalArchMain digitalArchMain);

    IPage<DigitalArchMain> getAllArchMain(IPage<DigitalArchMain> page,@Param("archMainTitle") String archMainTitle,@Param("username") String username);

    IPage<DigitalArchMain> getArchMainOne(IPage<DigitalArchMain> page,@Param("archMainTitle") String archMainTitle,@Param("username") String username);

    IPage<DigitalArchMain> getArchMainByState(IPage<DigitalArchMain> page,@Param("archState") int archState,@Param("archMainTitle") String archMainTitle);

    List<ArchTypeAndNumDto> getHotPointList();

    List<ArchTypeAndNumDto> getYearList();

    List<ArchTypeAndNumDto> getArchTypeList();

    IPage<DigitalArchMain>  getArchMainByHot(IPage<DigitalArchMain> page,@Param("typeName") String typeName);

    IPage<DigitalArchMain>  getArchMainByYear(IPage<DigitalArchMain> page,@Param("typeName") String typeName);

    IPage<DigitalArchMain>  getArchMainByCate(IPage<DigitalArchMain> page,@Param("typeName") String typeName);

    IPage<DigitalArchMain>  getArchMainByMuchType(IPage<DigitalArchMain> page,@Param("hotPoint") String hotPoint,@Param("year") String year,
                                                  @Param("cateType") String cateType);

    List<ArchMainTypeVo> getMyHotPoint(@Param("deptCode") String deptCode);


    List<ArchMainDto> getArchMainByCode(@Param("deptCode") String deptCode);

    List<CateAndYearDto> getCateByHotPoint(@Param("hotPoint") String hotPoint,@Param("deptCode") String deptCode);

    IPage<DigitalArchMain> qryMyDeptArchMainByType(IPage<DigitalArchMain> page,@Param("hotPoint") String hotPoint,@Param("year") String year,
                                                  @Param("cateCode") String cateCode,@Param("deptCode") String deptCode,@Param("archTitle") String archTitle);


}
